Skip to content

fix(ui): make the accordion trigger hover a state layer - #1137

Merged
vivek7405 merged 2 commits into
mainfrom
fix/accordion-hover-state-layer
Jul 27, 2026
Merged

fix(ui): make the accordion trigger hover a state layer#1137
vivek7405 merged 2 commits into
mainfrom
fix/accordion-hover-state-layer

Conversation

@vivek7405

Copy link
Copy Markdown
Collaborator

Closes #1136

Replaces the accordion trigger's hover dim with a background state layer, the pattern Material, Carbon, and Polaris specify for disclosure headers and the kit's own most-used hover treatment (hover:bg-accent hover:text-accent-foreground, the ghost-button and dropdown-item pair).

The dim it replaces landed with #1126 and communicated with the wrong vocabulary: reduced prominence is this kit's DISABLED axis (opacity-50, including on this very trigger), it lowered text contrast at the moment of interaction, and a text-only change cannot reveal the full-width hit area the way a tint does. Nothing has shipped in a release between the two, so this is invisible to users.

Also restores rest-colour inheritance on the label (the dim needed an explicit text-foreground; the state layer does not), and adds rounded-md -mx-2 px-2 so the tint hugs the row without misaligning the label from the panel content.

Test plan

  • Kit smoke 23 pass; website 128 pass; browser 35 pass.
  • Verified hovered in a real browser, light and dark, inside .ui-preview (where --accent is re-scoped to the kit's neutral values).
  • Disabled branch unchanged: pointer-events-none already suppresses the hover.

Doc surfaces

N/A beyond the in-file comment, which now records why the underline AND the dim were rejected. No markdown or docs-site page describes the trigger's hover; the ui package ships no changelog entry until its next release rolls this up.

Replaces the label dim that landed with #1126. Reduced prominence is
this kit's disabled vocabulary (opacity-50, including on this very
trigger), so dimming on hover said unavailable and under-your-pointer on
the same axis, and it lowered text contrast at the exact moment of
interaction. A background state layer is what Material, Carbon, and
Polaris specify for disclosure headers, and it is already the kit's own
most-used hover treatment (dropdown items, tabs), so the trigger now
uses the same hover:bg-accent pair as a ghost button.

The -mx-2/px-2 inset keeps the label aligned with the panel content
while the tint breathes around it, rounded-md keeps the tint from
reading as a table row, and dropping the explicit text-foreground
restores rest-colour inheritance, undoing the small behaviour change the
dim needed.

Verified hovered in a real browser in light and dark inside the gallery
preview scope.
@vivek7405 vivek7405 self-assigned this Jul 27, 2026
Review caught that width 100 percent plus symmetric negative margins is
over-constrained, so the browser drops the end-side margin: the tint
bled 8px past the left divider while stopping 8px short of the right
one, and the chevron sat 16px in from where every other row ends. A
summary styled as flex is a block-level box that already fills its
containing block, so removing w-full lets both negative margins apply.
Measured after: 8px overhang on both sides, label still aligned with
the panel content.

Also corrects the file's design-token doc line, which still declared
the foreground token this change stopped using and omitted the two
accent tokens it now does.

@vivek7405 vivek7405 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the state-layer change with fresh eyes and found two real things, both now fixed.

The substantive one: w-full plus symmetric negative margins is over-constrained under border-box sizing, so the browser silently drops the end-side margin. The tint bled 8px past the left divider while stopping 8px short of the right, and the chevron sat 16px in from where every other row ends, with the asymmetry flipping in RTL. The comment's claim of a symmetric overhang was false as written. A summary styled as flex is already a block-level box that fills its containing block, so dropping w-full is the whole fix; measured after at exactly 8px overhang both sides with the label still aligned to the panel content.

The small one: the file's design-token doc line still declared --foreground, which this change stopped using, and omitted the two accent tokens it now does use. That line is a maintained convention across the registry and is exactly what an agent theming a component reads first.

Also confirmed: the disabled branch cannot hover (pointer-events-none precedes any hover target), nothing in the repo asserts the old dim classes, the gitignored mirror regenerates byte-identically since this file has no lib imports, and the kit smoke suite passes with the substituted file.

Comment thread packages/ui/packages/registry/components/accordion.ts
Comment thread packages/ui/packages/registry/components/accordion.ts
@vivek7405
vivek7405 marked this pull request as ready for review July 27, 2026 17:39
@vivek7405
vivek7405 merged commit 30b9478 into main Jul 27, 2026
10 checks passed
@vivek7405
vivek7405 deleted the fix/accordion-hover-state-layer branch July 27, 2026 17:51
vivek7405 added a commit that referenced this pull request Jul 27, 2026
* Revert "fix(ui): make the accordion trigger hover a state layer (#1137)"

This reverts commit 30b9478.

* revert: restore the accordion trigger's hover underline

Completes the revert. The trigger is now byte-identical to what it was
before either of the two hover changes, back on shadcn's underline.

The reasoning I gave for replacing it (an underline reads as a link, and
this is a disclosure control) was not wrong on its own terms, but it was
not a problem anyone had, and shadcn parity is the stronger default for a
kit whose whole promise is that shadcn knowledge transfers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ui): accordion trigger hover should be a state layer, not a dim

1 participant